
/*
 * @Description: 
 * @Author: rendc
 * @Date: 2024-10-09 16:44:39
 * @LastEditors: rendc
 * @LastEditTime: 2024-10-09 16:57:11
 */
import java.util.Scanner;

/**
 * Test01Login
 */
public class Test01Login {
  public static void login(String username, String password) throws Exception {
    if (username.equals("root") && password.equals("briup")) {
      System.out.println("登录成功");
    } else {
      System.out.println("登录失败");
      // 编译时异常
      throw new Exception("登录失败:用户名密码有误");
    }
  }

  public static void main(String[] args) throws Exception {
    // 获取用户键盘输入
    Scanner sc = new Scanner(System.in);
    System.out.println("请输入用户名root");
    String name = sc.nextLine();
    System.out.println("请输入密码briup");
    String password = sc.nextLine();
    login(name, password);
  }

}